package com.dmxh.controller;


import com.alibaba.fastjson.JSONObject;
import com.dmxh.dto.UserDto;
import com.dmxh.pojo.TbUser;
import com.dmxh.result.Result;
import com.dmxh.result.ResultConstant;
import com.dmxh.service.UserService;
import com.dmxh.util.JwtUtil;
import com.dmxh.vo.UserVO;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author wxy
 * @since 2024-05-20
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    /*生成验证码*/
    @GetMapping("/generateCode/{phone}")
    public Result generateCode(@PathVariable("phone") String phone) {
        return Result.ok().setData(this.userService.generateCode(phone));
    }

    /*注册*/
    @PostMapping("/registerUser")
    public Result registerUser(@RequestBody UserDto userDto) {/*code放进dto里面了*/
        return Result.ok().setData(this.userService.registerUser(userDto));
    }


    /*查用户  这个接口没有前端调用   可以随时抛弃*/
    @GetMapping("/getUserAll")
    public Result getUserAll(){
        return Result.ok().setData(this.userService.getUserAll());
    }


}

